<?php

namespace Mallocu\NuitInfoBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Mallocu\NuitInfoBundle\Entity\Monument;

class DefaultController extends Controller {

    /**
     * @Route("/", name="site_index")
     * @Template()
     */
    public function indexAction() {
        $repoMonuments = $this->getDoctrine()->getRepository(Monument::REPO);
        $monuments = $repoMonuments->getMonumentsPageAccueil();
        $regions = $repoMonuments->getMonumentsImage();
        $regions = array_map(function(Monument $m) {
                    return $m->getRegion();
                }, $regions);
        array_unique($regions);
        sort($regions);
        return array(
            'regions' => $regions,
            'monuments' => $monuments
        );
    }

    /**
     * @Route("/monument/{id}", name="site_monument_show")
     * @Template()
     */
    public function monumentShowAction(Monument $monument) {

        return array(
            'monument' => $monument
        );
    }

}
